//
//  TableViewController.m
//  11217微博状态
//
//  Created by student on 16/3/8.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "TableViewController.h"
#import "StatusesModel.h"
#import "StatusesTableViewCell.h"
@interface TableViewController ()
@property(nonatomic,strong)NSArray *list;
@end

@implementation TableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.list=[StatusesModel statusArr];
    //注册单元格模板
    UINib *nib=[UINib nibWithNibName:@"StatusesTableViewCell" bundle:nil];
    [self.tableView registerNib:nib forCellReuseIdentifier:@"Cell"];
    
    //固定单元格高度
    //self.tableView.rowHeight=250;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.list.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    StatusesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    StatusesModel *status = self.list[indexPath.row];
    cell.status = status;

    
    
    return cell;
}

//预估高度
//-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    return 250;
//}

// 实际单元格高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    StatusesModel *m = self.list[indexPath.row];
    return m.cellHeight;
}

@end
